package com.osdp.common.feign.interceptor;

import com.osdp.common.constant.CommonConstant;
import com.osdp.common.util.TokenHolder;
import feign.RequestInterceptor;
import feign.RequestTemplate;

/**
 * 在Feign请求中加入token，同时标识请求为feign请求
 */
public class FeignTokenInterceptor implements RequestInterceptor{

    @Override
    public void apply(RequestTemplate requestTemplate) {
        String token = TokenHolder.getToken();
        requestTemplate.header(CommonConstant.HEADER_ACCESS_TOKEN,token);
        //标识为feign请求
        requestTemplate.header(CommonConstant.FEIGN_INVOKER,"true");
    }
}
